<?php
define('IN_ECS', true);
require('../includes/init.php');
include_once('../comm.php');
include_once('thumb.php');
$fmuid = isset($_SESSION['user_id'])?$_SESSION['user_id']:0;


extract($_POST);
$result = '';
//ȡͼƬ��ʵ���
$cal = NewMagickWand();
MagickReadImage ( $cal, '..'.$url );
$h = MagickGetImageHeight($cal);
$w = MagickGetImageWidth($cal);



//�ƶ��ļ���makedĿ¼
//Ŀ��·��
$fn = time(); //�ļ�������չ��
$filename = $fn.'.png'; //�ļ������չ��
$path = $fm_rootdir.'/uploads/maked/'.$fmuid.'/';
// �û�Ŀ¼�������򴴽�
$dir1 = '/uploads/maked/'.$fmuid.'/';
$dir2 = '..'.$dir1;
if(!is_dir($dir2)){
    mkdir($dir2);
}

$f1 = $dir1.$filename;
$target_file = $path.$filename;

if(copy($url, $target_file)){
	$result = "moved";
	//�ļ���Ϣ����ݿ�
	$query = "INSERT INTO `fmmaked`(uid,url,memo,width,height, aid)VALUES('$fmuid','$f1','$fn','$w','$h', '$idx')";
	$re = $GLOBALS['db']->query($query);
	if($re){
		$result = "success";
	}else{
		$result = "failure";
	}
}else{
	$result = 'failure';
}



$d = "<root><info><result>".$result."</result></info></root>";
echo $d;
?>
